import type { FC } from 'react';
import React, { useState } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-layout';
import type { ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { Button, Input, List } from 'antd';
import { useRequest } from 'umi';
import OperationModal from './components/OperationModal';
import { scanClassPackage } from './service';
import type { BasicListItemDataType } from './data.d';
import styles from './style.less';

export const BasicList: FC = () => {
  const [done, setDone] = useState<boolean>(false);
  const [visible, setVisible] = useState<boolean>(false);
  const [current, setCurrent] = useState<Partial<BasicListItemDataType> | undefined>(undefined);

  const {
    data: listData,
    loading,
    mutate,
  } = useRequest(() => {
    return scanClassPackage('com.items.dispatch');
  });

  const list = listData || [];

  //console.log(list);

  const paginationProps = {
    showSizeChanger: true,
    showQuickJumper: true,
    pageSize: 100,
    total: list.length,
  };

  const columns: ProColumns<BasicListItemDataType>[] = [
    {
      title: '包名',
      dataIndex: 'packagePath',
    },
    {
      title: '类名',
      dataIndex: 'className',
      tip: '规则名称是唯一的 key',
      search: false,
    },
    {
      title: '函数名',
      dataIndex: 'methodName',
      search: false,
    },
    {
      title: '参数类型',
      dataIndex: 'paramsType',
      search: false,
    },
    {
      title: '返回类型',
      dataIndex: 'paramsType',
      search: false,
    },
  ];

  const handleDone = () => {
    setDone(false);
    setVisible(false);
    setCurrent({});
  };

  const handleSubmit = (values: BasicListItemDataType) => {
    setDone(true);
    const method = values?.id ? 'update' : 'add';
  };

  return (
    <div>
      <PageContainer>
        <ProTable<BasicListItemDataType>
          headerTitle="查询表格"
          rowKey="packagePath"
          search={{
            labelWidth: 120,
          }}
          request={list}
          columns={columns}
        />
        <div className={styles.standardList}></div>
      </PageContainer>
    </div>
  );
};

export default BasicList;
